/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package myhashtable;

/**
 *
 * @author omega
 */
public class Test {

    public static void main(String[] args) {
        HashTable ht = new HashTable();
        ht.put("RRC", "1");
        ht.put("INA", "2");
        ht.put("IND", "3");
        ht.put("BRA", "4");
        ht.put("USA", "5");

        showHashMap(ht);
        ht.remove("INA");
        showHashMap(ht);
        ht.remove("BRA");
        showHashMap(ht);
        ht.remove("USA");
        showHashMap(ht);
        ht.remove("IND");
        showHashMap(ht);
        ht.remove("RRC");
        showHashMap(ht);
        ht.remove("INA");
        showHashMap(ht);


//        testLinkedListByKey();
//        testLinkedList();
    }

    public static void showHashMap(HashTable ht) {
        System.out.println(ht.get("USA"));
        System.out.println(ht.get("IND"));
        System.out.println(ht.get("INA"));
        System.out.println(ht.get("RRC"));
        System.out.println(ht.get("BRA"));
        System.out.println("-----------------");
    }

    public static void testLinkedListByKey() {
        LinkedList list = new LinkedList();
        list.add("ABC", "1");
        list.show();
        list.addWithSort("DBC", "2");
        list.show();
        list.addWithSort("CBC", "3");
        list.show();
        list.addWithSort("AAC", "4");
        list.show();
        list.addWithSort("FBC", "5");
        list.show();

        System.out.println("result1:" + list.getByKey("CBC"));
        System.out.println("result2:" + list.getByKey("FBC"));
        System.out.println("result3:" + list.getByKey("AAC"));
        System.out.println("result4:" + list.getByKey("aAC"));

        System.out.println("remove1:" + list.removeByKey("CBC"));
        list.show();
        System.out.println("remove2:" + list.removeByKey("FBC"));
        list.show();
        System.out.println("remove3:" + list.removeByKey("AAC"));
        list.show();
        System.out.println("remove4:" + list.removeByKey("DBC"));
        list.show();
        System.out.println("remove5:" + list.removeByKey("ABC"));
        list.show();
        System.out.println("remove6:" + list.removeByKey("CBC"));
        list.show();
    }

    public static void testLinkedList() {
        //        LinkedList list = new LinkedList();
//        list.add("1", "satu");
//        list.add("2", "dua");
//        list.add("3", "tiga");
//        list.add("4", "empat");
//        list.show();
//        System.out.println(list.get(1));
//        System.out.println(list.get(2));
//        System.out.println(list.get(3));
//        System.out.println(list.get(0));

//        list.insert(0, "5", "lima");
//        list.show();
//        list.insert(4, "6", "enam");
//        list.show();
//        list.insert(3, "7", "tujuh");
//        list.show();

//        list.set(0, "8", "delapan");
//        list.show();
//        list.set(3, "9", "sembilan");
//        list.show();
//        list.set(2, "10", "sepuluh");
//        list.show();

//        list.removeAll();
//        list.show();

//        list.remove(0);
//        list.show();
//        list.remove(2);
//        list.show();
//        list.remove(1);
//        list.show();
//        list.remove(0);
//        list.show();

        String a = "DBC";
        String b = "ABC";
        String c = "AnDi";
        String d = "azud";
        int hasil1 = a.compareTo(b);
        int hasil2 = a.compareTo(c);
        int hasil3 = a.compareTo(d);
        System.out.println("hasil:" + hasil1);
        System.out.println("hasi2:" + hasil2);
        System.out.println("hasi3:" + hasil3);
    }
}
